<script>
	var CONTROL = '__URL__';
	function change_code(obj){
	$("#code").attr("src", CONTROL+"/verify/"+Math.random());
	return false;
	}
$(document).ready(function () {
	//验证验证码
	$("input[name='validateCode']").blur(function(){
		var code = $("input[name='validateCode']");
		//alert(code.val().trim()); trim()--去掉两边空格
		if(code.val().trim() ==''){
			$("#message").html("验证码不能为空！");
			$("#addBtn").attr('disabled',true);
		}else{
			$("#message").html("");
			$("#addBtn").attr('disabled',false);
		}
	});
	$("input[name='validateCode']").change(function(){
		var code = $("input[name='validateCode']");
		$.post("{:U('Admin/Info/checkVerify')}",{validateCode:code.val().trim()},function (stat){
			if(stat==0){
				$("#message").html("验证码错误！");
				$("#addBtn").attr('disabled',true);
			}else if(stat==1){
				$("#message").html("");
			    $("#addBtn").attr('disabled',false);
			}
		});
	});
	$("input[name='name']").blur(function(){
		var name = $("input[name='name']");
		if(name.val().trim() == ''){
			$("#message").html("姓名不能为空！");
			$("#addBtn").attr('disabled',true);
		}else{
			$("#message").html("");
			$("#addBtn").attr('disabled',false);
		}
	});
	$("input[name='come']").blur(function(){
		var come = $("input[name='come']");
		if(come.val().trim() == ''){
			$("#message").html("请写明来自何方！");
			$("#addBtn").attr('disabled',true);
		}else{
			$("#message").html("");
			$("#addBtn").attr('disabled',false);
		}
	});
	$("input[name='theme']").blur(function(){
		var theme = $("input[name='theme']");
		if(theme.val().trim() == ''){
			$("#message").html("主题不能为空！");
			$("#addBtn").attr('disabled',true);
		}else{
			$("#message").html("");
			$("#addBtn").attr('disabled',false);
		}
	});
	$("textarea[name='content']").blur(function(){
		var content = $("textarea[name='content']");
		if(content.val() == ''){
			$("#message").html("内容不能为空！");
			$("#addBtn").attr('disabled',true);
		}else{
			$("#message").html("");
			$("#addBtn").attr('disabled',false);
		}
	});
})
</script>
<br>
<div class="container" style="width: 1000px;">
	<table  class="table table-bordered table-striped">
		<tbody>
			<tr>
				<td>
					<h2>	
						&nbsp;&nbsp;
						<span class="">&nbsp;&nbsp;
							<i class="glyphicon glyphicon-pushpin"></i>&nbsp;
							呵呵
						</span>
					</h2>
					<form  method="post" action="{:U('Admin/Info/message')}" id="" name="form1">
						<table class="table table-bordered table-striped" bordercolor="#C0C0C0">
							<tbody>
								<tr>
									<td  align="right" ><span lang="zh-cn">姓名：</span></td>
									<td style="width: 150px"><input  name="name" size="25" type="text"></td>
									<td style="width: 100px"><p align="right">来自：</p></td>
									<td style="width: 240px" ><input name="address" size="31" type="text"></td>
									<td colspan="2" align="right">交互栏目：</td>
									<td>
										<select size="1" name="lm" style="font-family: 微软雅黑; color: #FF0000; ">
											<option selected="" value="2"> 呵呵</option>
										</select>
									</td>
								</tr>
								<tr>
									<td align="right">主题：</td>
									<td colspan="4">
										<input  name="theme"  style="width: 540px" type="text">
									</td>
									<td align="right">验证码：</td>
									<td>
										<input  name="validateCode" style="width: 86px;height:27px;vertical-align:middle;" type="text">&nbsp;<img src="{:U('Index/verify')}" style="vertical-align:middle; width:86px; height:27px;" align="absmiddle" border="0" id="code"> <a href="javascript:void(change_code(this));"> <span style="color:#6A4898;">看不清</span></a>
									</td>
								</tr>
								<tr>
									<td align="right" valign="middle">内容：</td>
									<td colspan="6">
										<span>
											<textarea rows="9" name="consultContent" style="width: 900px"></textarea>
										</span>
										<span></span>
									</td>
								</tr>
							</tbody>
						</table>
						<!-- 判定是浏览者身份 1：登录用户（校内） 0：未登录用户（游客） -->
						<if condition="$_SESSION[account] eq ''">
							<input type="hidden" name="identity" value="0">
						<else />
							<input type="hidden" name="identity" value="1">	
						</if>
						<p align="center" id="message" style="color:red;"></p>
						<p align="center">
							<button id="addBtn" class="btn btn-mcit" style="margin-top: 30px; width: 150px; vertical-align: bottom;">提交</button>
						</p>
						<p align="center">　</p>
					</form>
					<br><br>
					<!-- content start -->
					<volist name="consult" id="consult">
						<if condition="$consult[data][status] eq 1">
							<div align="center">
								<table class="table">
									<tbody>
										<tr>
											<td align="right" class="style9" width="9%">姓&nbsp; 名:</td>
											<td class="style7" style="width: 21%" bgcolor="#FFFFFF">{$consult.name}</td>
											<td class="style8" width="10%"><p align="right" class="style10">来&nbsp; 自:</p></td>
											<td class="style7" bgcolor="#FFFFFF" width="15%">{$consult.address}</td>
											<td class="style8" width="8%"><p align="right" class="style10">发布时间:</p></td>
											<td class="style7" bgcolor="#FFFFFF" width="21%">{$consult.createTime}</td>
										</tr>
										<tr>
											<td align="right" class="style9" width="9%">主&nbsp; 题:</td>
											<td colspan="5" class="style7" bgcolor="#FFFFFF">{$consult.theme}</td>
										</tr>
										<tr>
											<td align="right" class="style9" width="9%">内&nbsp; 容:</td>
											<td colspan="5" class="style7" bgcolor="#FFFFFF">{$consult.consultContent}</td>
										</tr>
										<tr>
											<td align="right" class="style9" width="9%">回&nbsp; 
											复:</td>
											<td colspan="5" class="style7" bgcolor="#FFFFFF"><font color="#009933">{$consult.data.replyContent}</font><font color="#666666">(管理员于{$consult.data.replyTime}处理本留言)</font></td>
										</tr>
									</tbody>
								</table>
							</div><br>
						</if>
						<if condition="$consult[data][status] eq 2 and $consult[data][account] eq $_SESSION[name] ">
							<div align="center">
								<table class="table">
									<tbody>
										<tr>
											<td align="right" class="style9" width="9%">姓&nbsp; 名:</td>
											<td class="style7" style="width: 21%" bgcolor="#FFFFFF">{$consult.name}</td>
											<td class="style8" width="10%"><p align="right" class="style10">来&nbsp; 自:</p></td>
											<td class="style7" bgcolor="#FFFFFF" width="15%">{$consult.address}</td>
											<td class="style8" width="8%"><p align="right" class="style10">发布时间:</p></td>
											<td class="style7" bgcolor="#FFFFFF" width="21%">{$consult.createTime}</td>
										</tr>
										<tr>
											<td align="right" class="style9" width="9%">主&nbsp; 题:</td>
											<td colspan="5" class="style7" bgcolor="#FFFFFF">{$consult.theme}</td>
										</tr>
										<tr>
											<td align="right" class="style9" width="9%">内&nbsp; 容:</td>
											<td colspan="5" class="style7" bgcolor="#FFFFFF">{$consult.consultContent}</td>
										</tr>
										<tr>
											<td align="right" class="style9" width="9%">回&nbsp; 
											复:</td>
											<td colspan="5" class="style7" bgcolor="#FFFFFF"><font color="#009933">{$consult.data.replyContent}</font><font color="#666666">(管理员于{$consult.data.replyTime}处理本留言)</font></td>
										</tr>
									</tbody>
								</table>
							</div><br>
						</if>
					</volist>
					<!--备用页-->
					<!-- content end -->
					<!--<table class="table table-bordered table-striped">
					<tbody><tr>
					<td align="left" width="13%">当前页1/10</td>
					<td align="right" width="52%"> <a class="link" href="?page=1&amp;lm=2">首页</a> | 
					<a class="link" href="?page=2&amp;lm=2">下页</a> |
					<a class="link" href="?page=10&amp;lm=2">尾页</a> |转到第
					<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
					<option value="?page=1&amp;lm=2" selected="">1</option>
					<option value="?page=2&amp;lm=2">2</option>
					<option value="?page=3&amp;lm=2">3</option>
					<option value="?page=4&amp;lm=2">4</option>
					<option value="?page=5&amp;lm=2">5</option>
					<option value="?page=6&amp;lm=2">6</option>
					<option value="?page=7&amp;lm=2">7</option>
					<option value="?page=8&amp;lm=2">8</option>
					<option value="?page=9&amp;lm=2">9</option>
					<option value="?page=10&amp;lm=2">10</option>
					</select>页 
					</td>
					</tr>
					</tbody></table>-->
				</td>
			</tr>
		</tbody>
		<tr pid="0">
        	<td colspan="99" style="text-align:center">
            	<ul class="pagination">
                	{$pageView}
           	 	</ul>
        	</td>
		</tr>
	</table>
</div>
<br><br>
<script>
$(document).ready(function(){
    $("form").submit(function(){
        var name 		   = $("input[name='name']").val();
        var address 	   = $("input[name='address']").val();
        var theme 		   = $("input[name='theme']").val();
        var validateCode   = $("input[name='validateCode']").val();
        var consultContent = $("textarea[name='consultContent']").val();
        if(!$.trim(name)){
            alert('请填写姓名！');
            return false;
       }
       if(!$.trim(address)){
            alert('请填写来自何处！');
            return false;
       }
       if(!$.trim(theme)){
            alert('请填写主题！');
            return false;
       }
       if(!$.trim(validateCode)){
            alert('验证码不能空！');
            return false;
       }
       if(!$.trim(consultContent)){
            alert('请输入您要咨询的内容！');
            return false;
       }
   });
})
</script>